package com.panshi.modules.common.article;

import com.alibaba.fastjson.JSON;
import com.panshi.api.api.ArticleNoPort;
import com.panshi.api.api.ArticlePort;
import com.panshi.api.bean.ArticleBean;
import com.panshi.api.bean.ArticleNoBean;
import com.panshi.api.util.CommonResult;
import com.panshi.api.util.PageSizeVO;
import com.panshi.modules.common.service.ArctcleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author :jiege
 * @description :
 * @create :2020-08-13 10:00:00
 */
@Controller
@Api(tags = "文章管理")
public class ArticleController {


    @Autowired
    private ArticlePort articlePort;

    @Autowired
    private ArctcleService arctcleService;

    @GetMapping("/article/list")
    @RequiresPermissions("article:list")
    @ApiOperation("文章页面")
    public String articlepage(){
        return "/article/article-list";
    }

    @GetMapping("/article/listyes")
    @RequiresPermissions("article:list")
    @ResponseBody
    @ApiOperation("查询所有文章")
    public PageSizeVO queryallarticles(Integer currentPage, Integer pageSize){
        System.out.println(currentPage);
        System.out.println(pageSize);
        System.out.println(currentPage+"============"+pageSize);
        PageSizeVO<String> pageSizeBean = new PageSizeVO<>();
        pageSizeBean.setStartIndex(currentPage);
        pageSizeBean.setPageSize(pageSize);
        return articlePort.queryArticleVerifiedInfo(pageSizeBean);
    }

    @PostMapping("/article/update")
    @ResponseBody
    @RequiresPermissions("article:update")
    @ApiOperation("修改文章状态")
    public CommonResult<String> updateunanserlist(ArticleBean articleNoBean){
        articlePort.updateAssignArticleInfo(articleNoBean);
        arctcleService.send(articleNoBean);
        return new CommonResult<String>();
    }



}
